package com.test;

public class demo6 {

    public static void main(String[] args) {
        person pp = new person();
        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(pp);
            thread.start();
        }
        //pp.thread();
    }
}

class person implements Runnable {
    public void run() {
        synchronized (this) {
            try {
                Thread.sleep(1000);//设置时间为3秒
                System.out.println(Thread.currentThread().getName() + "--->过完独木桥");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public void thread() {
        person pp = new person();
        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(pp);
            thread.start();
        }
    }
}
